package cn.ycl.auth.biz.menu.controller;


import cn.ycl.auth.biz.menu.entity.Menubar;
import cn.ycl.auth.biz.menu.service.MenubarService;
import cn.ycl.syslog.OperationEnum;
import cn.ycl.syslog.SystemLog;
import cn.ycl.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (Menubar)表控制层
 *
 * @author makejava
 * @since 2020-12-03 20:50:06
 */
@RestController
@RequestMapping("/menubar")
public class MenubarController {
    /**
     * 服务对象
     */

    @Resource
    private MenubarService menubarService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne")
    public Menubar selectOne(Long id) {
        return this.menubarService.queryById(id);
    }


    /**
     * 获取菜单树
     */
    @SystemLog(value = "进入权限管理", type = OperationEnum.MENU_MANAGE)
    @GetMapping("/getMenuTree/{userId}")
    public AjaxResult getMenuTree(@PathVariable Long userId) {
        return AjaxResult.success(menubarService.getMenuTree(userId));
    }


}